const http = require('http')
const app = require('./module/route')
const ejs = require('ejs')

// 注册web服务
http.createServer(app).listen(3000);

// 配置路由
app.get('/', (req, res) => {
  res.send('首页')
})
app.get('/login', (req, res) => {
  ejs.renderFile('./views/form.ejs', {}, (err, data) => {
    res.end(data)
  })
})
app.get('/news', (req, res) => {
  res.send('新闻页面')
})
app.get('/register', (req, res) => {
  res.send('注册')
})

app.post('/doLogin', (req, res) => {
  res.send(req.body)
})

console.log('Server running at http://127.0.0.1:3000/');